package com.bianguo.android.apushdemo.utils;

import android.content.Context;
import android.content.SharedPreferences;

import com.bianguo.android.apushdemo.R;

/**
 * Created by Administrator on 2017/7/31.
 */

public class SharePreferenceUtil {

    private static SharePreferenceUtil sharePreferenceUtil;
    private SharedPreferences sharedPreferences;

    private SharePreferenceUtil(Context mContext){
        sharedPreferences = mContext.getSharedPreferences("APushDemoConfig", Context.MODE_PRIVATE);
    }

    public static SharePreferenceUtil getInstance(Context mContext){
        if (sharePreferenceUtil == null) {
            sharePreferenceUtil = new SharePreferenceUtil(mContext);
        }
        return sharePreferenceUtil;
    }

    public int getTheme(){
        return sharedPreferences.getInt("theme", 1);
    }
    public void setTheme(int theme) {
        SharedPreferences.Editor edit = sharedPreferences.edit();
        edit.putInt("theme", theme);
        edit.commit();
    }
}
